package com.zhongkai.controller;

import com.zhongkai.app.service.SetmodelService;
import com.zhongkai.model.utils.ZhongkaiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 公司产品
 * */
@Controller
public class SetmodelController {
    @Autowired
    private SetmodelService setmodelService;

    /**
     * 产品添加
     *
     * @param name 产品名称
     * @param unit 单位
     * @param cost 成本价格
     */
    @RequestMapping(value = "/set_model/add", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult model_add(String name ,String unit, String cost) {

        ZhongkaiResult result = setmodelService.addModel(name,unit,cost);

        return result;
    }


    /**
     * 产品列表
     * @param page 页数
     * @param rows 每页数据数量
     */
    @RequestMapping(value = "/set_model/list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult model_list(@RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "0")Integer rows) {

        ZhongkaiResult result = setmodelService.getModelList(page,rows);

        return result;
    }


    /**
     * 产品修改
     *
     * @param name 产品名称
     * @param unit 单位
     * @param cost 成本价格
     * @param uuid 产品uuid
     */
    @RequestMapping(value = "/set_model/update", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult model_update(String name, String unit, String cost, String uuid) {

        ZhongkaiResult result = setmodelService.updateModel(name,unit,cost,uuid);

        return result;
    }



    /**
     * 产品删除
     *
     * @param uuid 产品uuid
     */
    @RequestMapping(value = "/set_model/remove", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult model_remove(String uuid) {

        ZhongkaiResult result = setmodelService.removeModel(uuid);

        return result;
    }
}
